function exchange(nums: number[]): number[] {
    const res:number[] = [];
    nums.forEach((r:number) => {
        if (r % 2 === 0) {
            res.push(r)
        } else {
            res.unshift(r);
        }
    })
    return res;
};